package com.dxl.system.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dxl.base.Result;
import com.dxl.base.Results;
import com.dxl.system.mapper.LabelNoteMapper;
import com.dxl.system.model.LabelNote;
import com.dxl.system.service.LabelNoteService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <b> 标签文件关联服务接口实现类
 * </b><br><br><i>Description</i> :
 * <br>Date: 2019-09-25    <br>Author : dxl
 */
@Service
public class LabelNoteServiceImpl extends ServiceImpl<LabelNoteMapper,LabelNote> implements LabelNoteService {

    @Autowired(required = false)
    private LabelNoteMapper labelNoteMapper;

    /**
     * <b> 插入标签文件关联
     * </b><br><br><i>Description</i> : 
     * @param labelNote LabelNote
     * @return com.dxl.base.Result LabelNote
     * <br><br>Date: 2019-09-25    <br>Author : dxl
     */
    @Override
    public Result addOne(LabelNote labelNote) {
        labelNoteMapper.insert(labelNote);
        return Results.successWithData(labelNote);
    }

    /**
     * <b> 删除标签文件关联
     * </b><br><br><i>Description</i> : 
     * @param labelNoteIds List: Integer
     * @return com.dxl.base.Result int
     * <br><br>Date: 2019-09-25    <br>Author : dxl
     */
    @Override
    public Result delByIds(List<Integer> labelNoteIds) {
        int num = labelNoteMapper.deleteBatchIds(labelNoteIds);
        return Results.successWithData(num);
    }


    /**
     * <b> 编辑标签文件关联
     * </b><br><br><i>Description</i> : 
     * @param labelNote LabelNote
     * @return com.dxl.base.Result LabelNote
     * <br><br>Date: 2019-09-25    <br>Author : dxl
     */
    @Override
    public Result editOne(LabelNote labelNote) {
        labelNoteMapper.updateById(labelNote);
        return Results.successWithData(labelNote);
    }

    /**
     * <b> ID查询标签文件关联
     * </b><br><br><i>Description</i> : 
     * @param labelNoteId Integer
     * @return com.dxl.base.Result: LabelNote
     * <br><br>Date: 2019-09-25    <br>Author : dxl
     */
    @Override
    public Result getById(Integer labelNoteId) {
        LabelNote labelNote = labelNoteMapper.selectById(labelNoteId);
        return Results.successWithData(labelNote);
    }

    /**
     * <b> 条件查询标签文件关联
     * </b><br><br><i>Description</i> : 
     * @param labelNote LabelNote
     * @return com.dxl.base.Result List: LabelNote
     * <br><br>Date: 2019-09-25    <br>Author : dxl
     */
    @Override
    public Result getList(LabelNote labelNote) {
        QueryWrapper<LabelNote> labelNoteWrapper = new QueryWrapper<LabelNote>(labelNote);
        List<LabelNote> labelNoteList = labelNoteMapper.selectList(labelNoteWrapper);
        return Results.successWithData(labelNoteList);
    }

    /**
     * <b> 分页条件查询标签文件关联
     * </b><br><br><i>Description</i> : 
     * @param labelNote LabelNote, currentPage -Integer, pageSize -Integer
     * @return com.dxl.base.Result List: LabelNote
     * <br><br>Date: 2019-09-25     <br>Author : dxl
     */
    @Override
    public Result getListByPage(LabelNote labelNote, Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage, pageSize);
        List<LabelNote> labelNoteList = (List<LabelNote>) getList(labelNote).getData();
        PageInfo<LabelNote> pageInfo = new PageInfo<LabelNote>(labelNoteList);
        return Results.successWithData(pageInfo);
    }


}
